﻿using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hCommand {
    public class LocOrderUtil {
        public static void finshCoreTask(IDbConnection conn, IDbTransaction tran, long id)
        {
            string sql = @"update core_task set Status={0},Finsh_Time=sgj_get_sys_now where  id=@id";
            sql = String.Format(sql, (int)CoreTaskStatus.结束);
            conn.Execute(sql, new  { id}, tran);
        }
        public static  void nearOrder(List<CoreWhLoc> all,  int x, int y,int Scale=1) {
         
            foreach (CoreWhLoc loc in all) {
                loc.orderNo = Math.Abs(loc.x - x) + Math.Abs(loc.y - y)* Scale;
            }

            all.Sort(new LocComparer());

        }
    }


    class LocComparer : IComparer<CoreWhLoc> {
        public int Compare(CoreWhLoc loc1, CoreWhLoc loc2) {
            
                return loc1.orderNo.CompareTo(loc2.orderNo);
        }
    }
 
}
